package com.lanou.service.imp;

import com.lanou.bean.Blog;
import com.lanou.bean.User;
import com.lanou.mapper.UserMapper;
import com.lanou.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by dllo on 18/2/26.
 */
@Service
public class UserServiceImp implements UserService{
    @Resource
    private UserMapper userMapper;
    @Override
    public void regist(User user){
        /*InputStream stream = Resources.getResourceAsStream("SSM-mybatis.xml");
        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(stream);
        SqlSession session = sessionFactory.openSession();
        UserMapper mapper = session.getMapper(UserMapper.class);
        mapper.addUser(user);
        session.commit();*/
        userMapper.addUser(user);
    }

    @Override
    public User login(String name,String password) {
        User user = userMapper.findalluser(name,password);
        if (user != null && user.getPassword().equals(password)) {
            return user;
        }
        return null;
    }

    @Override
    public User selectuid(String name) {
        return userMapper.selectuid(name);
    }

}
